/*
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 * http://www.gnu.org/licenses/gpl-3.0.html
 *
 * $Revision: 11004 $
 * $Id: dlgabout.cpp 11004 2017-02-07 23:35:46Z fuscated $
 * $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-17.xx/src/src/dlgabout.cpp $
 */

#include "sdk.h"

#ifndef CB_PRECOMP
    #ifdef __WXMAC__
        #include <wx/font.h>
    #endif //__WXMAC__
    #include <wx/button.h>    // wxImage
    #include <wx/image.h>    // wxImage
    #include <wx/intl.h>
    #include <wx/stattext.h>
    #include <wx/string.h>
    #include <wx/textctrl.h>
    #include <wx/xrc/xmlres.h>

    #include "licenses.h"
    #include "configmanager.h"
#endif

#include <wx/bitmap.h>
#include <wx/dcmemory.h>    // wxMemoryDC
#include <wx/statbmp.h>

#include "appglobals.h"
#include "dlgabout.h" // class's header file
#include "configmanager.h"
#include "splashscreen.h"

// class constructor

dlgAbout::dlgAbout(wxWindow* parent)
{
    if (!wxXmlResource::Get()->LoadObject(this, parent, _T("dlgAbout"), _T("wxScrollingDialog")))
    {
        cbMessageBox(wxT("从XRC文件加载'关于'对话框时出错."),wxT("信息"), wxICON_EXCLAMATION);
        return;
    }

    wxButton *cancelButton = XRCCTRL(*this, "wxID_CANCEL", wxButton);
    cancelButton->SetDefault();
    cancelButton->SetFocus();

    const wxString description =wxString::Format(wxT("欢迎使用%s %s! \n"
                                                     "%s是一个功能齐全的IDE(集成开发环境),"
                                                     "旨在使单个开发人员(和开发团队)在一个良好的编程环境中工作,提供他/他们从此类程序所需的一切."
                                                     "它的可插入架构允许您,开发人员,向核心程序添加任何类型的功能,通过使用插件...")
                                                             ,appglobals::AppName,
                                                             appglobals::AppVersion,
                                                             appglobals::AppName);

    wxString file = ConfigManager::ReadDataPath() + _T("/images/splash_1312.png");
    wxImage im; im.LoadFile(file, wxBITMAP_TYPE_PNG); im.ConvertAlphaToMask();
    wxBitmap bmp(im);
    wxMemoryDC dc;
    dc.SelectObject(bmp);
    cbSplashScreen::DrawReleaseInfo(dc);

    wxStaticBitmap *bmpControl = XRCCTRL(*this, "lblTitle", wxStaticBitmap);
    bmpControl->SetSize(im.GetWidth(),im.GetHeight());
    bmpControl->SetBitmap(bmp);

    XRCCTRL(*this, "lblBuildTimestamp", wxStaticText)->SetLabel(wxString(wxT("构建时间: ")) + appglobals::AppBuildTimestamp);
    XRCCTRL(*this, "txtDescription",    wxTextCtrl)->SetValue(description);
    XRCCTRL(*this, "txtThanksTo",       wxTextCtrl)->SetValue(wxT(
        "开发者:\n"
        "--------------\n"
        "Yiannis Mandravellos: 开发者 - 项目负责人\n"
        "Thomas Denk         : 开发者\n"
        "Lieven de Cock      : 开发者\n"
        "\"tiwag\"             : 开发者\n"
        "Martin Halle        : 开发者\n"
        "Biplab Modak        : 开发者\n"
        "Jens Lody           : 开发者\n"
        "Yuchen Deng         : 开发者\n"
        "Teodor Petrov       : 开发者\n"
        "Daniel Anselmi      : 开发者\n"
        "Yuanhui Zhang       : 开发者\n"
        "Damien Moore        : 开发者\n"
        "Micah Ng            : 开发者\n"
        "Ricardo Garcia      : 专业写手\n"
        "Paul A. Jimenez     : 帮助文档和AStyle插件\n"
        "Thomas Lorblanches  : CodeStat和Profiler插件\n"
        "Bartlomiej Swiecki  : wxSmith RAD插件\n"
        "Jerome Antoine      : ThreadSearch插件\n"
        "Pecan Heber         : Keybinder, BrowseTracker, DragScroll\n"
        "                      CodeSnippets插件\n"
        "Arto Jonsson        : CodeSnippets 插件 (传给山核桃[Pecan])\n"
        "Darius Markauskas   : Fortran支持\n"
        "Mario Cupelli       : 嵌入式系统的编译器支持\n"
        "                      用户手册\n"
        "Jonas Zinn          : 杂项及wxSmith插件\n"
        "Mirai Computing     : cbp转make工具\n"
        "Anders F Bjoerklund : wxMac兼容\n"
        "\n"
        "贡献者(无特殊顺序):\n"
        "-----------------------------------\n"
        "Daniel Orb          : RPM规范文件和包\n"
        "byo,elvstone, me22  : Unicode转换\n"
        "pasgui              : 提供Ubuntu nightly包\n"
        "Hakki Dogusan       : DigitalMars编译器支持\n"
        "ybx                 : OpenWatcom编译器支持\n"
        "Tim Baker           : 直接编译模式的修补程序\n"
        "                      依赖项生成系统\n"
        "David Perfors       : Unicode测试者和未来的文档编写器\n"
        "Sylvain Prat        : 初始MSVC工作区和项目导入程序\n"
        "Chris Raschko       : Code::Blocks的三维标志设计\n"
        "J.A. Ortega         : 基于以上的三维图标\n"
        "Alexandr Efremo     : 提供OpenSuSe包\n"
        "Huki                : 杂项及代码完成改进\n"
        "stahta01            : 杂项及几个增强的修补程序\n"
        "BlueHazzard         : 杂项及几个增强的修补程序\n"
        "\n"
        "提供修补程序的所有贡献者.\n"
        "wxWidgets项目(http://www.wxwidgets.org).\n"
        "wxScintilla项目(http://sourceforge.net/projects/wxscintilla).\n"
        "TinyXML解释器(http://www.grinninglizard.com/tinyxml).\n"
        "Squirrel脚本语言(http://www.squirrel-lang.org).\n"
        "GNU软件基金会(http://www.gnu.org).\n"
        "最后,但并非最不重要的是,开源社区."));
    XRCCTRL(*this, "txtLicense", wxTextCtrl)->SetValue(LICENSE_GPL);

    XRCCTRL(*this, "lblName",    wxStaticText)->SetLabel(appglobals::AppName);
    XRCCTRL(*this, "lblVersion", wxStaticText)->SetLabel(appglobals::AppActualVersionVerb);
    XRCCTRL(*this, "lblSDK",     wxStaticText)->SetLabel(appglobals::AppSDKVersion);
    XRCCTRL(*this, "lblAuthor",  wxStaticText)->SetLabel(wxT("Code::Blocks团队"));
    XRCCTRL(*this, "lblEmail",   wxStaticText)->SetLabel(appglobals::AppContactEmail);
    XRCCTRL(*this, "lblWebsite", wxStaticText)->SetLabel(appglobals::AppUrl);

#ifdef __WXMAC__
    // Courier 8 point is not readable on Mac OS X, increase font size:
    wxFont font1 = XRCCTRL(*this, "txtThanksTo", wxTextCtrl)->GetFont();
    font1.SetPointSize(10);
    XRCCTRL(*this, "txtThanksTo", wxTextCtrl)->SetFont(font1);

    wxFont font2 = XRCCTRL(*this, "txtLicense", wxTextCtrl)->GetFont();
    font2.SetPointSize(10);
    XRCCTRL(*this, "txtLicense", wxTextCtrl)->SetFont(font2);
#endif
    Fit();
    CentreOnParent();
}

// class destructor
dlgAbout::~dlgAbout()
{
    // insert your code here
}
